package br.org.blacklist.web.componentes;

import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;

import br.org.blacklist.model.governamental.Instituicao;
import br.org.blacklist.model.governamental.TipoPoderPublico;
import br.org.blacklist.web.index.IndexWebPage;

public class InstituicaoPainelFormulario extends Panel {

    private static final long serialVersionUID = 1L;

    public InstituicaoPainelFormulario(String id, Instituicao model) {
        super(id);
        IModel<Instituicao> componente = new CompoundPropertyModel<Instituicao>(model);
        Form<Instituicao> form = new Form<Instituicao>("instituicao-form", componente);
        form.add(new TextField<String>("nome"));
        form.add(new TextArea<String>("descricao"));
        form.add(new DropDownChoice<TipoPoderPublico>("poder", TipoPoderPublico.toArray()));
        add(form);
    }

    public class CancelarLink extends Link<String> {

        private static final long serialVersionUID = 1L;

        public CancelarLink(String id) {
            super(id);
        }

        @Override
        public void onClick() {
            setResponsePage(IndexWebPage.class);
        }

    }

}
